package site.marqstree.kotlin.library.good.ui.fragment.category.centent.recyclerview

import com.chad.library.adapter.base.BaseNodeAdapter
import com.chad.library.adapter.base.entity.node.BaseNode
import site.marqstree.kotlin.library.good.ui.fragment.category.centent.ContentFragment
import site.marqstree.kotlin.library.good.ui.fragment.category.centent.bean.CategoryContentBean
import site.marqstree.kotlin.library.good.ui.fragment.category.centent.bean.FootBean
import site.marqstree.kotlin.library.good.ui.fragment.category.centent.bean.BrandBean
import site.marqstree.kotlin.library.good.ui.fragment.category.centent.recyclerview.provider.FooterNodeProvider
import site.marqstree.kotlin.library.good.ui.fragment.category.centent.recyclerview.provider.RootNodeProvider
import site.marqstree.kotlin.library.good.ui.fragment.category.centent.recyclerview.provider.SecondNodeProvider


/*
 * 项目名: KotlinMall
 * 包名: site.marqstree.kotlin.library.good.ui.fragment.category.centent.recyclerview
 * 文件名: ContentAdapter
 * 创建者: marqstree
 * 创建时间: 2020/3/7 15:07
 * 描述: TODO
 */
class ContentAdapter(val mFragment:ContentFragment): BaseNodeAdapter() {

    init{
        animationEnable = true
        addFullSpanNodeProvider(RootNodeProvider())
        addNodeProvider(SecondNodeProvider())
        addFooterNodeProvider(FooterNodeProvider())
    }

    override fun getItemType(data: List<BaseNode>, position: Int): Int {
        val node = data[position]
        if (node is CategoryContentBean) {
            return 0
        } else if (node is BrandBean) {
            return 1
        } else if (node is FootBean) {
            return 2
        }
        return -1
    }

}